package com.str.algorithm;
public class Factorial {

	public static long factorial(int n) {
        long product = 1;
        for (int i=1; i<=n; i++)
            product *= i;
        return product;
    }
	
	public static long factorial2(int n) {
		if (n == 0) 
		  return 1;
		else
	      return n * factorial2(n - 1);
	}
   
    public static void main(String[] args) {
  	    for (int n = 0; n <= 10; n++)
 		    System.out.println("n = " + n +
		        "\tn! = " + factorial(n) + "  " + factorial2(n));
	}
}
